package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/3/15 17:15
 * @description
 */
public class Code204 {
    public static void main(String[] args) {
        System.out.println(new Code204().countPrimes(10));
        System.out.println(8 ^ 2 ^ 3 ^ 4 ^ 2 ^ 5 ^ 8 ^ 4 ^ 5);
    }

    public int countPrimes(int n) {
        boolean[] isPrime = new boolean[n + 1];
        int count = 0;
        for (int i = 2; i < n; i++) {
            if (!isPrime[i]) {
                count++;
                for (int j = i + i; j < n; j += i) {
                    isPrime[j] = true;
                }
            }
        }
        return count;
    }
}
